package org.giovanolli.mumi.dao.impl;

import org.giovanolli.mumi.dao.HelpItemDao;
import org.giovanolli.mumi.entities.HelpItem;
import org.giovanolli.mumi.entities.filter.EntityFilter;
import org.giovanolli.mumi.entities.filter.HelpItemFilter;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 * The Class HelpItemDaoImpl.
 */
@Repository("helpItemDao")
public class HelpItemDaoImpl extends HibernateDao<HelpItem> implements HelpItemDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.giovanolli.mumi.dao.impl.HibernateDao#fillCriteria(org.giovanolli .mumi.entities.filter.EntityFilter, org.hibernate.criterion.DetachedCriteria)
	 */
	@Override
	protected DetachedCriteria fillCriteria(EntityFilter<HelpItem> filter, DetachedCriteria criteria) {
		final HelpItemFilter entityFilter = (HelpItemFilter) filter;

		if (filter != null) {
			criteria.add(Restrictions.eq("helpId", entityFilter.getHelpId()));
		}
		return criteria;
	}

}
